//
//  TabBarController.m
//  zhangchu
//
//  Created by aoyolo on 15/10/22.
//  Copyright (c) 2015年 李祖铜. All rights reserved.
//

#import "TabBarController.h"
#import "RecipeViewController.h"
#import "LoveViewController.h"
#import "FoodClassViewController.h"
#import "MyViewController.h"



@interface TabBarController ()

@end

@implementation TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpAllChildViewController];
  
}

#pragma mark - 添加所有的子控制器
-(void)setUpAllChildViewController
{
    
    RecipeViewController *recipeCtl = [[RecipeViewController alloc]init];
    UINavigationController *recipeNav = [[UINavigationController alloc]initWithRootViewController:recipeCtl];
    
    LoveViewController *loveCtl = [[LoveViewController alloc]init];
    UINavigationController *loveNav = [[UINavigationController alloc]initWithRootViewController:loveCtl];
    
    FoodClassViewController *foodClassCtl = [[FoodClassViewController alloc]init];
    UINavigationController *foodClassNav = [[UINavigationController alloc]initWithRootViewController:foodClassCtl];
    
    MyViewController *myCtl = [[MyViewController alloc]init];
    UINavigationController *myNav = [[UINavigationController alloc]initWithRootViewController:myCtl];
    //添加所有tarBar图片
    UIImage *recipeImg =[UIImage imageNamed:@"食谱A"];
    UIImage *recipeImgs = [UIImage imageNamed:@"食谱B"];
    
    UIImage *loveImg = [UIImage imageNamed:@"喜欢A"];
    UIImage *loveImgs = [UIImage imageNamed:@"喜欢B"];
    
    UIImage *foodClassImg = [UIImage imageNamed:@"食课A"];
    UIImage *foodClassImgs = [UIImage imageNamed:@"食课B"];
    
    UIImage *myImg = [UIImage imageNamed:@"我的A"];
    UIImage *myImgs = [UIImage imageNamed:@"我的B"];
    
    //创建选择器的切换卡
    //食谱
    UITabBarItem *recipeItem = [[UITabBarItem alloc]initWithTitle:@"食谱" image:[recipeImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[recipeImgs imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    [recipeItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [recipeItem setTitleTextAttributes:@{NSForegroundColorAttributeName:appColor} forState:UIControlStateSelected];
    //喜欢
    UITabBarItem *loveItem = [[UITabBarItem alloc]initWithTitle:@"喜欢" image:[loveImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[loveImgs imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    [loveItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [loveItem setTitleTextAttributes:@{NSForegroundColorAttributeName:appColor} forState:UIControlStateSelected];
    //食客
    UITabBarItem *foodClassItem = [[UITabBarItem alloc]initWithTitle:@"食课" image:[foodClassImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[foodClassImgs imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    [foodClassItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [foodClassItem setTitleTextAttributes:@{NSForegroundColorAttributeName:appColor} forState:UIControlStateSelected];
    //我的
    UITabBarItem *myItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:[myImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[myImgs imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    [myItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [myItem setTitleTextAttributes:@{NSForegroundColorAttributeName:appColor} forState:UIControlStateSelected];
    
    
    recipeNav.tabBarItem = recipeItem;
    loveNav.tabBarItem = loveItem;
    foodClassNav.tabBarItem = foodClassItem;
    myNav.tabBarItem = myItem;
    
    self.viewControllers = @[recipeNav, loveNav, foodClassNav, myNav];
}



@end
